Object-Oriented Programming Languages (OOPLs) have been developed to improve the productivity of developing software programs. The OOPLs typically include Java (developed by Sun Microsystems, Inc.) and other programming languages conforming to CLI (Common Language Infrastructure)(developed by Microsoft Corporation). Employing OOPLs, program developers can create small, reusable sections of program code known as “objects”. The objects, once created, can be quickly and easily combined and re-used to create new programs.
Compilation for a software program written in such languages typically involves having each of its objects in source code format individually compiled by a compiler into a processor-executable native or machine code file (i.e., compiled object file). The compiled object files are then processed by a linker, which combines the compiled object files to produce a complete executable program. The executable program is then eligible for execution on a computer system.
To improve the performance of the executable program, the program needs to be optimized during compilation. One prior solution to optimize the executable program is to have each of the compilers perform the optimizing transformations to the object file it compiles. Known optimization operations performed by a compiler typically include base binding, function cloning, and partial evaluation.
However, one problem of the above-described prior solution is that the compilers cannot have the knowledge of the entire program (i.e., lacks the “whole program view”) during compilation because the program contains object files that are compiled separately. This means that many optimizing transformation operations at compile-time depend on information that is only available at link-time of the program. Thus, even though a compiler is capable of performing an optimizing transformation operation based on a particular piece of information, the compiler may not be able to do so if the required information for the optimization operation is not available at that time. The linker, on the other hand, is not powerful enough to perform any optimizing transformation operation, which typically requires heavy analysis of the program code and knowledge of the target instruction set structure. A linker does not require code analysis and knowledge of target instruction structure during linking.
One prior solution to the above-described problems is to employ a link-time optimizer that optimizes the entire executable program at link-time. However, the prior link-time optimizer is typically a heavyweight tool, which typically makes the link-time optimization much more expensive than the compile-time optimization. In addition, the link-time optimizer needs to perform its own code analysis for the optimizing transformation (i.e., not being able to take advantage of the code analysis performed by the compiler).
Thus, there exists a need for a method and system of performing link-time code optimization without additional code analysis.